import java.util.ArrayList;

public class Node {
	private String type;
	private String name;
	private Node parent;
	private ArrayList<Node> children;
	private boolean visited;

	int i;

	public Node(String type, String name, Node parent, ArrayList<Node> children) {
		this.type = type;
		this.visited = false;
		this.name = name;
		this.parent = parent;
		if (children == null)
			this.children = new ArrayList<Node>();
		else
			this.children = children;
	}

	public boolean isVisited() {
		return visited;
	}

	public void setVisited(boolean visited) {
		this.visited = visited;
	}

	public String getName() {
		return name;
	}

	public Node getParent() {
		return parent;
	}

	public ArrayList<Node> getChildren() {
		return children;
	}

	public void setParent(Node parent) {
		this.parent = parent;
	}

	public void addChild(Node child) {
		children.add(child);
	}

	public void printTree() {
		i = 0;
		int id = i;
		// System.out.println("HEAD = " + this.name + "; id# " + id);
		System.out.println("Currently=(" + this.type + "," + this.name
				+ "); NO PARENT; Children=(");
		for (Node n : this.getChildren()) {
			System.out.print(n.type + "," + n.name + "###");
		}
		System.out.println(")");
		System.out.println();
		for (Node n : this.getChildren()) {
			recursePrint(this, n, id);
		}
	}

	public void recursePrint(Node prev, Node curr, int prevId) {
		i++;
		// System.out.println("CURRENTLY = " + curr.name + " of id# " + i
		// + "; FROM = " + prev.name + " of id# " + prevId);
		System.out.println("Currently=(" + curr.type + "," + curr.name
				+ "); Parent=(" + prev.type + "," + prev.name + "); Children=(");
		for (Node n : curr.getChildren()) {
			System.out.print(n.type + "," + n.name + "###");
		}
		System.out.println(")");
		System.out.println();
		int id = i;
		for (Node n : curr.getChildren()) {
			recursePrint(curr, n, id);
		}
	}
}
